import React, { Component } from 'react';
import Taro from '@tarojs/taro';
import {Image, View} from '@tarojs/components'
import {platform} from '../../utils/platform-settting.service';
import './support-bar.scss'

class SupportBar extends Component {
  state: {
    support_phone: any
    support_title: any
    ivcheng_img: any
    hideWc: any
  } = {
    support_phone: '',
    support_title: '',
    ivcheng_img: '',
    hideWc: 0
  }

  async UNSAFE_componentWillMount() {
    if (platform.support) {
      this.setState({
        hideWc: platform.info.hideWc,
        support_phone: platform.support.support_phone || '',
        ivcheng_img: platform.support.ivcheng_img || '',
        support_title: platform.support.support_title || ''
      })
    }
  }

  render() {
    const {hideWc,ivcheng_img, support_title, support_phone} = this.state
    return (
      <View className={hideWc == 0 ? "support-wrap" : 'support-wrap hide'}>
        <View className='support'>
          {!support_phone && <View className='ivcheng_img'><Image className='img' src={ivcheng_img} mode='widthFix' /></View>}
          <View className='support-title'>{support_title}</View>
          <View className='support-phone'>{support_phone}</View>
        </View>
      </View>
    )
  }
}

export default SupportBar
